<?php

/*
 * *	FILE NAME: 	main.php 	(Last Update: 24 NOVEMBER 2011)
 * * 	DESCRIPTION: -
 * *	 
 * *	LICENSE:	
 * *
 * *	@programmer	-
 * *	@license	
 * *	@version	Release: @1.0@
 * *	@link		http://www.domain.com/package/packagename
 * *	@since		File available since Release 1.0
 * *
 */

$params = require(dirname(__FILE__) . '/params.' . YII_ENVIRONMENT . '.php');
$db = require(dirname(__FILE__) . '/database.' . YII_ENVIRONMENT . '.php');

// preview theme
if (isset($_GET['theme']) && !empty($_GET['theme']))
    $params['theme'] = $_GET['theme'];

return array(
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => $params["title"],
    'theme' => $params["theme"],
    'defaultController' => 'topic', 
    //'sourceLanguage' => 'en_us',
    'language' => $params['defaultLanguage'],
    'preload' => array('log'),
    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.components.extended.*',
        'ext.libs.*',
        'ext.interfaces.*',
        'ext.yii-mail.YiiMailMessage',
        //'ext.widgets.shoppingCart.*',
        //'ext.widgets.bucket.*',
    ), //end import
    
    'components' => array(
        /*
         * Database configuration
         */
        'db' => array(
            //'class' => 'system.db.CDbConnection',
            'class' => 'ext.PHPPDO.CPdoDbConnection',
            'pdoClass' => 'PHPPDO',
            'connectionString' => $db["dsn"],
            'username' => $db["username"],
            'password' => $db["password"],
            'charset' => $db["charset"],
            'tablePrefix' => $db["tablePrefix"],
            'emulatePrepare' => $db["emulatePrepare"], // needed for some MySQL installations
            //'enableProfiling' => true, //for database profiling
            'schemaCachingDuration' => 86400,
            'initSQLs' => array(
            ),
        ), //end db
        
        'authManager' => array(
            'class' => 'CPhpAuthManager',
            //'authFile' => '',
            'defaultRoles' => array('guest'),
        ),//end authManager
        
        /*
         * Site URL configuration.
         */
        'urlManager' => array(
            'urlFormat' => 'path',
            //'urlSuffix' => '.html',
            'showScriptName' => false,
            'rules' => require(dirname(__FILE__) . '/urlRules.php'),
        ), //end urlManager

        /*
         * Application log configuration
         */
        'log' => array(
            'class' => 'CLogRouter',
            'routes' => require(dirname(__FILE__) . '/logRoutes.' . YII_ENVIRONMENT . '.php'),
        ), //end log

        /*
         * Site messages configuration
         */
        'messages' => array(
            'class' => 'CPhpMessageSource',
        ), //end messages

        /*
         * cache configuration
         */
        'cache' => array(
            'class' => 'system.caching.CFileCache', // compulsory for 'settings' components
        ), //end cache

        /*
         * Define default error handling page
         */
        'errorHandler' => array(
            'errorAction' => 'site/error',
        ), //end errorHandler
        
        /**
         * Auto start session
         */
        'session' => array(
            'autoStart' => true,
        ),//end session
        
        /*
         * 
         */
        'request' => array(
            'enableCsrfValidation' => true, // Cross-site Request Forgery Prevention (CSRF )
            'enableCookieValidation' => true, // Cookie Attack Prevention
        ), //end request


        /*
         * Member login configuration
         */
        'user' => array(
            'class' => 'WebUser',
            'allowAutoLogin' => true, // enable cookie-based authentication
            'loginUrl' => array('user/auth/login'), //member module
            'returnUrl' => array('user/site/index'),
            //'autoUpdateFlash' => false,
        ), //end user
        
        'response'=>array(
            'class'=>'ext.libs.WebResponse',
            'responseAction'=>'site/response',
        ),//end response
        
        'simpleImage'=>array(
            'class' => 'ext.widgets.simpleImage.CSimpleImage',
        ),//end simpleImage
                
        'geoip' => array(
            'class' => 'ext.geoip.CGeoIP',
            // specify filename location for the corresponding database
            'filename' => dirname(dirname(__FILE__)) . '/data/geoip/GeoIP.dat', //'C:\path\to\GeoIP\GeoLiteCity.dat',
            // Choose MEMORY_CACHE or STANDARD mode
            'mode' => 'STANDARD',
        ),//end geoip
        
        'contentCompactor' => array(
            'class' => 'ext.contentCompactor.ContentCompactor',
            'options' => array(
                'compress_css' => true, // Compress CSS
                'strip_comments' => true, // Remove comments
                'keep_conditional_comments' => true, // Remove conditional comments
                'compress_horizontal' => true, // Compress horizontally
                'compress_vertical' => true, // Compress vertically
                'compress_scripts' => true, // Compress inline scripts using basic algorithm
                'line_break' => PHP_EOL, // The type of rowbreak you use in your document
                'preserved_tags' => array('textarea', 'pre', 'script', 'style', 'code'),
                'preserved_boundry' => '@@PRESERVEDTAG@@',
                'conditional_boundries' => array('@@IECOND-OPEN@@', '@@IECOND-CLOSE@@'),
                'script_compression_callback' => false,
                'script_compression_callback_args' => array(),
            ),
        ),
        
        /*
         * php mailer
         */
        'mail' => array(
            'class' => 'ext.yii-mail.YiiMail',
            'transportType' => 'php',
            'viewPath' => 'application.views.edm',
            'logging' => true,
            'dryRun' => false,
        ),//end mail
        
        /*
        'shoppingCart' => array(
            'class' => 'ext.widgets.shoppingCart.EShoppingCart',
        ),//end shopping cart
        */
        
        /*
         * Settings table configuration
         */
        'settings' => array(
            'class' => 'CmsSettings',
            'cacheComponentId' => 'cache',
            'cacheId' => 'global_wsys_settings',
            'cacheTime' => 84000,
            'tableName' => '{{settings}}',
            'dbComponentId' => 'db',
            'createTable' => true,
            'dbEngine' => 'InnoDB',
        ), //end settings

        /**
         * 
         */
        'format' => array(
            'class' => 'Formatter',
            'currencySymbol' => $params['defaultCurrency'],
            'countryCode' => $params['defaultCountryCode'],
        ), //end format
    ),
    /** end components * */
        
    /*
     * Site available modules
     */
    'modules' => array(
        'gii' => require(dirname(__FILE__) . '/gii.php'), // disable this in production for security purpose.
        'install', // disable this in production for security purpose.
        'mytest', // disable this in production for security purpose.
        'user',
        'account',
        'acp',
        'edm',
        'api',
    ),
    /** end modules * */
    /*
     * Site params
     */
    'params' => $params,
);